package leetcode.code1630;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import leetcode.IDebug;
import leetcode.helper.H;

public class Solution implements IDebug {

	public List<Boolean> checkArithmeticSubarrays(int[] nums, int[] l, int[] r) {
		List<Boolean> ans = new ArrayList<>();
		for (int i = 0; i < r.length; i++) {
			int[] arr = Arrays.copyOfRange(nums, l[i], r[i] + 1);
			Arrays.sort(arr);
			int dif = arr[1] - arr[0];
			boolean cur = true;
			for (int j = 2; j < arr.length; j++) {
				if (arr[j] - arr[j - 1] != dif) {
					cur = false;
					break;
				}
			}
			ans.add(cur);
		}
		return ans;
	}

	@Override
	public void debug4() {
		H.print(this.checkArithmeticSubarrays(H.str2array3("[4,6,5,9,3,7]"), H.str2array3("[0,0,2]"),
				H.str2array3("[2,3,5]")));

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();

	}

}
